""" pathfinding.py implements a pathfinding algorithm and returns the path
as a list.
"""
thisMonster.Path.Clear() #Empty the path

thisMonster.Path.Push(Vector3(thisMonster.TargetTile.X, 0, thisMonster.TargetTile.Z)) #Path is a stack
																		  #so add the last step
																		  #first.
curX = thisMonster.TilePosition.X
curZ = thisMonster.TilePosition.Z

while curX != thisMonster.TargetTile.X or curZ != thisMonster.TargetTile.Z:
	if curX < thisMonster.TargetTile.X:
		curX = curX + 1
	elif curX > thisMonster.TargetTile.X:
		curX = curX - 1
		
	if curZ < thisMonster.TargetTile.Z:
		curZ = curZ + 1
	elif curZ > thisMonster.TargetTile.Z:
		curZ = curZ - 1
		
	thisMonster.Path.Push(Vector3(curX, 0, curZ))

thisMonster.AiState.Pop() #Pathfinding is done